package com.ruo.goods.controller;

import com.ruo.common.core.domain.R;
import com.ruo.goods.domain.PmsProductCategory;
import com.ruo.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：尚志豪
 * @Package：com.ruo.goods.controller
 * @Project：ruoi
 * @name：GoodsColntroller
 * @Date：2024/7/18 19:11
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;


    /**
     * 商品分类列表
     */
    @PostMapping("/typeList")
    public R<List<PmsProductCategory>> typeList(@RequestParam Integer id){
        List<PmsProductCategory> list = goodsService.typeList(id);
        return R.ok(list);
    }
    /**
     * 下拉框
     */
    @PostMapping("/dropDownDox")
    public R<List<PmsProductCategory>>  dropDownDox(){
        List<PmsProductCategory>  r = goodsService.dropDownDox();
        return R.ok(r);
    }


    /**
     * 商品分类添加
     */
    @PostMapping("/typeAdd")
    public R typeAdd(@RequestBody PmsProductCategory category){
        R r = goodsService.typeAdd(category);
        return r;
    }
    /**
     * 商品分类删除
     */
    @PostMapping("/typeDel")
    public R typeDel(@RequestParam Integer id){
        R r = goodsService.typeDel(id);
        return r;
    }
    /**
     * 商品分类修改
     */
    @PostMapping("/typeUpdate")
    public R typeUpdate(@RequestBody PmsProductCategory category){
        R r = goodsService.typeUpdate(category);
        return r;
    }
    /**
     * 商品分类回显
     */
    @PostMapping("/typeEcho")
    public R<PmsProductCategory> typeEcho(@RequestParam Integer id){
        PmsProductCategory r = goodsService.typeEcho(id);
        return R.ok(r);
    }
    /**
     * 开关
     */
    @PostMapping("/updateById")
    public R updateById(@RequestBody PmsProductCategory category ){
        R r = goodsService.typeUpdate(category);
        return r;
    }


}
